package br.com.dataphonebr.selectListener;

import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;

public class CalculatorListener implements OnClickListener{
	
	private static final String CALCULATOR_PACKAGE_NAME = "com.android.calculator2";
	private static final String CALCULATOR_CLASS_NAME = "com.android.calculator2.Calculator";


	@Override
	public void onClick(View v) {
		launchCalculator(v.getContext());
	}
	
	public void launchCalculator(Context context) {
		Intent intent = new Intent();
		intent.setAction(Intent.ACTION_MAIN);
		intent.addCategory(Intent.CATEGORY_LAUNCHER);
		intent.setComponent(new ComponentName(CALCULATOR_PACKAGE_NAME, CALCULATOR_CLASS_NAME));
		try {
			context.startActivity(intent);
		} catch (ActivityNotFoundException noSuchActivity) {
			noSuchActivity.printStackTrace();
		}
	}

}
